package de.rosmi.beispiele.twitterdsl
import javax.swing.plaf.metal.MetalIconFactory.FolderIcon16;

import javax.swing.plaf.metal.MetalIconFactory.FolderIcon16;

import org.codehaus.groovy.control.CompilerConfiguration;

String.metaClass.search = {Closure c ->
	GeeTwitterScript.search (delegate, c)
}

args = ["./src/TestTwitter4J.groovy"]

if (args) {
	//Variante 1: Script-Konfiguration anpassen
//	def conf = new CompilerConfiguration()
//	conf.setScriptBaseClass "GeeTwitterScript"

	//Variante 2: Script-Bindings anpassen
	def binding = new Binding()
	binding.login = GeeTwitter.&login
	binding.sendMessage = GeeTwitter.&sendMessage
	binding.follow = GeeTwitter.&follow
	binding.search = GeeTwitter.&search
	binding.eachFollower = GeeTwitter.&eachFollower
	binding.eachFriend = GeeTwitter.&eachFriend
	
	//Variante 1
	//def shell = new GroovyShell(conf)
	//Variante 3
	def shell = new GroovyShell(binding)
	shell.evaluate (new File(args[0]))
}
else {
	println "Usage: Geetwitter <script>"
}